package com.wqj.kyee.gps.custom;

import android.util.Log;

import com.github.mikephil.charting.charts.BarLineChartBase;
import com.github.mikephil.charting.components.AxisBase;
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
import com.wqj.kyee.gps.nmea.NMEA;

import java.util.ArrayList;

/**
 * Created by Administrator on 2018/1/29.
 */

public class SVAxisValueFormatter implements IAxisValueFormatter {

    private static final String TAG = "SVAxisValueFormatter";

    private BarLineChartBase<?> chart;
    private ArrayList<NMEA.SVInfo> mSVList;

    public SVAxisValueFormatter(BarLineChartBase<?> chart) {
        this.chart = chart;
    }


    public void setSVList(ArrayList<NMEA.SVInfo> list) {
        this.mSVList = list;
    }

    @Override
    public String getFormattedValue(float value, AxisBase axis) {

        if (this.mSVList == null) {
            Log.e(TAG, "Error svlist is null");
            return "Err";
        }

        int index = (int) value;

        if (index >= mSVList.size())
            return "Out";

        NMEA.SVInfo sv = this.mSVList.get(index);
        if (sv.isGPS()) {
            return "G" + sv.PRN;
        } else if (sv.isSBAS()) {
            return "S" + sv.PRN;
        } else if (sv.isGLONASS()) {
            return "R" + sv.PRN;
        } else if (sv.isBEIDOU()) {
            return "B" + sv.PRN;
        } else if (sv.isQZSS()) {
            return "Q" + sv.PRN;
        } else if (sv.isGALILEO()) {
            return "E" + sv.PRN;
        }

        return "U" + sv.PRN;
    }
}
